<?php

/*
 * activite/reload-new.phtml
 */
?>
<table class='table table-striped list-table'>
    <thead>
	<tr>
	    <td width="10%">Code</td>
	    <td width="25%">Libellé</td>
	    <td width="20%">Couleur</td>
	    <td width="35%">Description</td>
	    <td width="10%">&nbsp;</td>
	</tr>
    </thead>
    <tbody>
	<tr>
	    <td style='text-align: center'>
		<a href='#' id='code' data-type='text'></a>
	    </td>
	    <td style='text-align: center'>
		<a href='#' id='libelle' data-type='text'></a>
	    </td>
	    <td style='text-align: center'>
		<input type='text' id='couleur' value=''>
	    </td>
	    <td style='text-align: center'>
		<a href='#' id='description' data-type='textarea'></a>
	    </td>
	    <td style='text-align: center'>
		<button class='btn btn-success' id="ajouter" onclick='return addNew();' style="display: none;">Ajouter</button>
	    </td>
	</tr>
    </tbody>
</table>
</div>
<form id='newCode' action='#' method='post'>
    <input type='hidden' id='new-id' name='id' value='0'>
    <input type='hidden' id='new-code' name='code' value=''>
    <input type='hidden' id='new-libelle' name='libelle' value=''>
    <input type='hidden' id='new-couleur' name='couleur' value=''>
    <input type='hidden' id='new-description' name='description' value=''>
</form>
<form id='editCode' action='#' method='post'>
    <input type='hidden' id='edit-id' name='id' value='0'>
    <input type='hidden' id='edit-code' name='code' value=''>
    <input type='hidden' id='edit-libelle' name='libelle' value=''>
    <input type='hidden' id='edit-couleur' name='couleur' value=''>
    <input type='hidden' id='edit-description' name='description' value=''>
</form>
<script type="text/javascript">
    $(function(){
	// Editable
	$('#code').editable({
	    title : 'Edition du Code',
	    validate : function(value){
		$('#new-code').val(value);
		if($('#new-libelle').val() != ''){
		    $('#ajouter').show();
		}else{
		    $('#ajouter').hide();
		}
	    }
	});
	$('#libelle').editable({
	    title : 'Edition du Libellé',
	    validate : function(value){
		$('#new-libelle').val(value);
		if($('#new-code').val() != ''){
		    $('#ajouter').show();
		}else{
		    $('#ajouter').hide();
		}
	    }
	});
	$('#description').editable({
	    title : 'Edition de la Description',
	    validate : function(value){
		$('#new-description').val(value);
	    }
	});
	$('#couleur').spectrum({
	    color: '#fff',
	    flat: false,
	    showInput : true,
	    showInitial: true,
	    chooseText: "Sélectionner",
	    cancelText: "Annuler",
	    preferredFormat: "hex6",
	    showSelectionPalette: true,
	    localStorageKey: "spectrum.homepage",
	    clickoutFiresChange: true,
	    move: function(color) {
		$('#new-couleur').val(color.toHexString());
	    }
	});
    });
</script>